export default {
	data() {
		return {
			cWidth: 0,
			cHeight: 0,
			canvas: true,
			arr: [],
			categories:[],
			series:[],
			transaction_time: 30,
			serverData:{
				chartType: "line",
				extraType: "curve",
				id: "order_total",
				opts:{
					
				}
			}
		}
	},
	onShow() {

	},
	methods: {		
		//图表
		init() {
			this.cWidth = uni.upx2px(690);
			this.cHeight = uni.upx2px(540);
			this.getServerData();
		},
		nextPage() {
			if (this.page < this.page_count) {
				this.page++;
				this.getorderList();
			}
		},	
		//获取统计的图表信息
		getorderHead() {
			let url = '/fenxiao/api/shop/orderHead';
			let data = {
				date: this.period.join('-')
			};
			data.site_id = this.id;
			data.order_status = this.listNavValue;
			this.$api.sendRequest({
				url: url,
				data: data,
				success: res => {
					this.statsData = res.data;
					this.categories =  res.data.time;
					
					this.series = [{
						name: '线上交易额',
						data: res.data.online,
						color: '#FF4544',
						time: res.data.time
					},{
						name: '线下交易额',                                         
						data: res.data.offline,
						color: '#12D0AE',
						time: res.data.time
					}];
					
					this.init();
					this.$refs.order_total.changeData(this.serverData.id,this.serverData.opts);
					if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
				}
			});                            
		},
		getorderList() {
			let url = '/fenxiao/api/shop/orderDetail';
			let data = {
				page: this.page,
				page_size: this.page_size,
				date: this.period.join('-')
			};
			data.site_id = this.id;
			data.order_status = this.listNavValue;
			this.$api.sendRequest({
				url: url,
				data: data,
				success: res => {
					let newArr = [];
					newArr = res.data.list;
					this.list = this.list.concat(newArr);
					this.page_count = res.data.page_count;
				}
			});
		},
		getServerData(categories,series) {
			var Data = {
				enableScroll: false,
				yAxisdisabled: true,
				xAxisgridColor: 'transparent',
				yAxisgridType: 'dash',
				yAxisgridColor: '#eeeeee',
				animation: true,
				enableScroll: true,
				scrollColor: 'transparent',
				scrollPosition: 'right',
				scrollBackgroundColor: 'transparent',
				categories:[...this.categories],
				series:[...this.series],
				extra: {
					area: {
						addLine: true,
						opacity: 0.5,
						width: 2,
						color: '#FF6A00',
						type: 'curve'
					},
				},
				legend: true
			}
			
			this.serverData = {
				...this.serverData,
				opts: Data
			};
		}
	},
	onReachBottom() {
		this.nextPage();
	}
}
